<?php require_once('../Connections/informeUrb.php'); ?>
<?php session_start();

$usuario = $_SESSION['usuario'];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

$identificador = $_GET['ID'];
$dniCam=$_POST['dni'];
unset($_SESSION['dni']);
$_SESSION['dniNuevo']=$dniCam;

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE usuarios  SET Nombre='%s', Apellidos='%s', Dni='%s', Edad='%s',Telefono='%s', Provincia='%s', Localidad='%s', Direccion='%s', Email='%s', Cp='%s' WHERE idUsuario='$identificador'",
                       $_POST['nombre'], 
                       $_POST['apellido'],
                       $_POST['dni'], 
                       $_POST['edad'], 
                       $_POST['telefono'],
					   $_POST['provincia'], 
                       $_POST['localidad'], 
                       $_POST['direccion'],
					   $_POST['email'], 
                       $_POST['cp']);

mysql_select_db($database_informeUrb, $informeUrb);                                          
$Result1 = mysql_query($updateSQL, $informeUrb) or die(mysql_error());

//$updateSQL1 = sprintf("UPDATE preferencias  SET Teatro='%s', Operas='%s', Cine='%s', Futbol='%s',Baloncesto='%s', Otros='%s', Toros='%s', Concierto='%s' WHERE dniUsuario='$dniCam'",
//                       $_POST['teatro'], 
//                       $_POST['opera'],
//                       $_POST['cine'], 
//                       $_POST['futbol'], 
//                       $_POST['baloncesto'],
//					   $_POST['otros'], 
//                       $_POST['toros'], 
//                       $_POST['conciertos']);
//                       
//mysql_select_db($database_informeUrb, $informeUrb);                                          
//$Result2 = mysql_query($updateSQL1, $informeUrb) or die(mysql_error());


	
?>
 <script>
  	window.location.href="index.php";
  </script>
 <?php
}

$colname_MODIFICAR = "-1";
if (isset($_GET['ID'])) {
  $colname_MODIFICAR = (get_magic_quotes_gpc()) ? $_GET['ID'] : addslashes($_GET['ID']);
}

mysql_select_db($database_informeUrb, $informeUrb);
$query_MODIFICAR = sprintf("SELECT * FROM usuarios WHERE idUsuario='$identificador'", $colname_MODIFICAR);
$MODIFICAR = mysql_query($query_MODIFICAR, $informeUrb) or die(mysql_error());
$row_MODIFICAR = mysql_fetch_assoc($MODIFICAR);

$dniUsu=$row_MODIFICAR['Dni'];
$totalRows_MODIFICAR = mysql_num_rows($MODIFICAR);

$colname_MODIFICAR1 = "-1";
if (isset($_GET['ID'])) {
  $colname_MODIFICAR1 = (get_magic_quotes_gpc()) ? $_GET['ID'] : addslashes($_GET['ID']);
}
mysql_select_db($database_informeUrb, $informeUrb);
$query_MODIFICAR1 = sprintf("SELECT * FROM preferencias WHERE dniUsuario= '$dniUsu'", $colname_MODIFICAR1);
$MODIFICAR1 = mysql_query($query_MODIFICAR1, $informeUrb) or die(mysql_error());
$row_MODIFICAR1 = mysql_fetch_assoc($MODIFICAR1);

$totalRows_MODIFICAR1 = mysql_num_rows($MODIFICAR1);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Sistema Reventa Entradas Teatro</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../login/programas.js" type="text/javascript"></script>
<script>
function volver(){
	parent.location.href='index.php';
}

</script>
</head>
<body>
<div id="header">
	<div id="logo">
		<h1><a href="#"></a></h1>
		<h2><a href=""> </a></h2>
	</div>
	<div id="menu">
		<ul>
			<li><a href="../index.php" accesskey="1" title="Inicio">Inicio</a></li>
			<li><a href="#" accesskey="2" title="Login" onclick="funcion1a()">Login</a></li>
			<li><a href="../administrador/index.php" accesskey="3" title="Administracion">Administracion	</a></li>
			<li><a href="../foro/index.php" accesskey="4" title="Sobre Nosotros">Foro</a></li>
			<li><a href="../contacto/contactform.htm" accesskey="5" title="Contacta">Contacta</a></li>
		</ul>
	</div>
</div>

<div id="login">
<div id="tabla2" style="display:none;">  
  	<form action="ingresar.php" method="post">
    <table align="center" width="68%">
	<tr>
		<td class="imgTituloTabla">
			<div class="tituloTabla">Panel Control</div>
		</td>
	</tr>
	</table>
	<?php if (!isset($_SESSION['usuario'])) {?>
	<table align="center" width="25%" class="bordeTablaGris">
	<tr valign="baseline">
      <td nowrap align="right" class="letraLogin">Usuario:</td>
      <td><input type="text" name="nick" size=28 maxlength=20></input></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right" class="letraLogin">Contrase&ntilde;a:</td>
      <td><input type="password" name="pass" size=28 maxlength=20></input></td>
    </tr>     
  </table>
  <h1 class="letraLogin2" style="text-align: center; color: white;">Si no estas registrado pincha <a href="../login/registro.php"  ><strong style="color: white;">aqui</strong></a></h1>
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="">&nbsp;</td>
     <td> <input type="submit" class="boton" value="Ingresar"></input></td>
    </tr>
    <?php }else{
    	?><table align="center" width="35%" >
    	<tr><td><?php 
    	echo "Usuario:".$_SESSION['usuario'];
    	?>
    	</td>
    	</tr> 
    	<tr><td><a  class="letraLogin" style="text-align: right; color: white;" href="index.php">Mi Zona</a></td></tr>     
        <tr><td><a  class="letraLogin" style="text-align: right; color: white;" href="../salir.php">Cerrar Seccion</a></td></tr>
    <?php 
    } ?>
   </table>   
  	</table>
      </form>
  	</div>
</div>

<div id="splash"><img src="../img/Portada.jpg" alt="" width="500" height="120" style="margin-left: 15%;" /></div>
<br></br>

<form method="post" name="form1" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>" onSubmit="return valida(this);">
	
	<table align="center" width="100%">
	<tr>
		<td class="imgTituloTabla">
			<div class="tituloTabla">Formulario Para Modificar Datos de Usuario</div>
		</td>
	</tr>
	</table>	
	<table align="center" width="100%" class="bordeTablaGris">
	<tr valign="baseline">
      <td align="right" class="letraLogin">Nombre:</td>
      <td><input type="text" name="nombre" value="<?php echo $row_MODIFICAR['Nombre']; ?>" size="32" class="inputTexto"></input></td>
    </tr>	
     <tr valign="baseline">
      <td align="right" class="letraLogin">Apellidos:</td>
      <td><input type="text" name="apellido" value="<?php echo $row_MODIFICAR['Apellidos']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
    <tr valign="baseline">
      <td align="right" class="letraLogin">NIF:</td>
      <td><input type="text" name="dni" value="<?php echo $row_MODIFICAR['Dni']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
    <tr valign="baseline">
      <td align="right" class="letraLogin">Edad:</td>
      <td><input type="text" name="edad" value="<?php echo $row_MODIFICAR['Edad']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
    <tr valign="baseline">
      <td align="right" class="letraLogin">Telefono:</td>
      <td><input type="text" name="telefono" value="<?php echo $row_MODIFICAR['Telefono']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
     <tr valign="baseline">
      <td align="right" class="letraLogin">Provincia:</td>
      <td><input type="text" name="provincia" value="<?php echo $row_MODIFICAR['Provincia']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
	<tr valign="baseline">
      <td align="right" class="letraLogin">localidad:</td>
      <td><input type="text" name="localidad" value="<?php echo $row_MODIFICAR['Localidad']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
    <tr valign="baseline">
      <td align="right" class="letraLogin">Direccion:</td>
      <td><input type="text" name="direccion" value="<?php echo $row_MODIFICAR['Direccion']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
    <tr valign="baseline">
      <td align="right" class="letraLogin">Email:</td>
      <td><input type="text" name="email" value="<?php echo $row_MODIFICAR['Email']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
    <tr valign="baseline">
      <td  align="right" class="letraLogin">Cod. Postal:</td>
      <td><input type="text" name="cp" value="<?php echo $row_MODIFICAR['Cp']; ?>" size="32" class="inputTexto"></input></td>
    </tr>
   </table>    
    <table align="center">
 		<tr valign="baseline">
      <td  >&nbsp;</td>
     <td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Volver" onclick="volver()" class="inputTexto"></input><input type="submit" value="Registrar" class="inputTexto"></input></td>
    </tr>
  	</table>
	<input type="hidden" name="MM_update" value="form1">
    <input type="hidden" name="id" value="<?php echo $row_MODIFICAR['idUsuario']; ?>">
</form>
	<div style="clear: both;">&nbsp;</div>
<div id="footer">
	<p>Copyright &copy; 2011 . Designed by <strong>Melli</strong></a></p>
</div>
    </body>
</html>
<?php
mysql_free_result($MODIFICAR);
?>
   


